package com.kuaigou.cim.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.appleframework.config.core.PropertyConfigurer;
import com.appleframework.distributed.id.IdWorker2;
import com.appleframework.jms.rocketmq.producer.RocketMessageProducer2;
import com.kuaigou.cim.service.TruckerTrailSendService;
import com.kuaigou.common.model.bean.Track;

@Service("truckerTrailSendService")
public class TruckerTrailSendServiceImpl implements TruckerTrailSendService {
	
	private static String KEY_TOPIC = "producer.trail.topic";
	
	private static String KEY_TAGS = "producer.trail.tags";
	
	@Resource
	private RocketMessageProducer2 messageProducer;
	
	@Resource
	private IdWorker2 idWorker;

	@Override
	public void send(List<Track> list) {		
		String topic = PropertyConfigurer.getString(KEY_TOPIC);
		String tags = PropertyConfigurer.getString(KEY_TAGS);	
		for(Track track:list){
			messageProducer.sendObject(topic, tags,idWorker.nextId() + "", track);
		}

	}

}
